package org.example.shardiing.config;

import org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import javax.sql.DataSource;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;

@Configuration
public class DataSourceConfig {


    // ShardingSphere 数据源
    @Bean(name = "shardingsphere")
    public DataSource shardingDataSource() throws SQLException, IOException {
        return YamlShardingSphereDataSourceFactory.createDataSource(new File(
                "D:\\workspace\\shardiing\\src\\main\\resources\\shardingsphere-jdbc.yml"));
    }


}
